//
//  LineLabelControl.m
//  WangLottery
//
//  Created by 黄修勇 on 12-5-16.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "LineLabelControl.h"

@interface LineLabelControl (Private)

-(void)setDefault;

@end

@implementation LineLabelControl

@synthesize text=_text;


-(void)setDefault{

    [self addTarget:self action:@selector(touchDown) forControlEvents:UIControlEventTouchDown];
    [self addTarget:self action:@selector(touchMove) forControlEvents:UIControlEventTouchUpInside];
    underLineLabel=[[UnderLineLabel alloc]initWithFrame:CGRectZero];
    underLineLabel.backgroundColor=[UIColor clearColor];
    underLineLabel.textColor=[UIColor redColor];
    underLineLabel.font=[UIFont systemFontOfSize:14.0f];
    [self addSubview:underLineLabel];
}

-(id)initWithFrame:(CGRect)frame{

    self=[super initWithFrame:frame];
    if (self) {
        [self setDefault];
    }
    return self;
}

-(id)initWithCoder:(NSCoder *)aDecoder{

    self=[super initWithCoder:aDecoder];
    if (self) {
        [self setDefault];
    }
    return self;
}

-(void)setText:(NSString *)text{

    underLineLabel.text=text;
}

-(NSString *)text{

    return underLineLabel.text;
    [self layoutSubviews];
}

-(void)touchDown{

    underLineLabel.textColor=[UIColor whiteColor];
}

-(void)touchMove{

    underLineLabel.textColor=[UIColor redColor];
}


-(void)layoutSubviews{

    underLineLabel.frame=CGRectMake(self.frame.size.width/2-underLineLabel.frame.size.width/2, self.frame.size.height/2-underLineLabel.frame.size.height/2, underLineLabel.frame.size.width, underLineLabel.frame.size.height);
}
@end
